import BaseService from '../BaseService'
import factory from '../serviceFactory'
import SystemConstant from '@/constants/System'

class ReportService extends BaseService {
  /**
   * 按销售明细分页查询
   * querySalesReportPage({...})
   */
  querySalesReportPage = factory.makeGet('/api/report/querySalesReportPage')

  /**
   * 销售报表查询（除明细之外的查询）
   * querySalesReportList({...})
   */
  querySalesReportList = factory.makeGet('/api/report/querySalesReportList')

  /**
   * 导出
   */
  exportSalesReport = (param) => {
    const arr = []
    for (let key in param) {
      if (param.hasOwnProperty(key) && param[key]) {
        arr.push(key + '=' + encodeURIComponent(param[key]))
      }
    }
    return SystemConstant.CTX + '/api/report/exportSalesReport?' + arr.join('&')
  }
}

export default new ReportService()
